package business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import vo.Log;
import business.LogService;
import dao.LogDAO;

public class LogServiceImpl implements LogService {

	private LogDAO logDao;

	public List<Log> getAllLogs() {
		return logDao.findAll();
	}

	public List<Log> getAllLogs(int start,int pageSize) {
		return logDao.findAll(start,pageSize);
	}
	public long getTotalCount() {
		return logDao.findTotalCount();
	}

	public List<Log> getByUserIdMessage(long userId,String msg) {
		return logDao.findByUserIdMessage(userId,msg);
	}

	public List<Log> getByUserIdType(long userId,String type) {
		return logDao.findByUserIdType(userId,type);
	}
	public List<Log> getByUserId(long userId) {
		return logDao.findByUserId(userId);
	}

	@Required
	public void setLogDao(LogDAO logDao) {
		this.logDao = logDao;
	}

	@Transactional
	public void addLog(String name) {
		Log e = new Log();
		logDao.create(e);
	}

	@Transactional
	public void addLog(Log log) {
		logDao.create(log);
	}
	@Transactional
	public Log getById(long id) {
		return logDao.getById(id);
	}

	@Transactional
	public void update(long id) {
		logDao.update(id);
	}

	@Transactional
	public void delete(long id) {// 真正删除
		logDao.delete(id);
	}

}